﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BibMan.util {
    public class IdentifiableList<TKey, TValue> : ObservableDictionary<TKey, TValue> where TValue : IIdentifiable<TKey> {

        public new TValue this[TKey key] {
            get {
                return base[key];
            }
            set {
                TValue old = this[key];
                if (!value.Id.Equals(key)) throw new ArgumentException("The ID and the key do not match.");
                base[key] = value;
                //FireUpdated(key, old, value);
            }
        }

        public new void Add(TKey key, TValue value) {
            if (!value.Id.Equals(key)) throw new ArgumentException("The ID and the key do not match.");
            base.Add(key, value);
            //FireAdded(key, value);
        }

    }
}
